package com.zmj.entity;

public class Page {
	
	
	private int currentPage=1;//当前页，默认第一页
	private int pageSize=5;//每页展示多少条记录
	private int pageCount;//总页数
	private int count;//总记录数
	private int start;//记录起始数
	
	private int upPage;//上一页
	private int downPage;//下一页
	
	
	public Page() {
		
	}
	
	public Page(int start,int pageSize) {
		
		this.pageSize = pageSize;
		this.start = start;
	}

	public Page(int currentPage, int pageSize, int count) {
		
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.count = count;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		
		this.currentPage = currentPage;
		this.upPage=currentPage-1<0?1:currentPage-1;
		this.downPage=currentPage+1>pageCount?pageCount:currentPage+1;
		this.start=(currentPage-1)*pageSize;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getPageCount() {
		return pageCount;
	}
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		
		this.count = count;
		int t=this.count/pageSize;
		if (this.count%pageSize!=0) {
			t++;
		}
		this.pageCount=t;
	}
	public int getStart() {
		return start;
	}
	public void setStart(int start) {
		this.start = start;
	}
	public int getUpPage() {
		return upPage;
	}
	public void setUpPage(int upPage) {
		this.upPage = upPage;
	}
	public int getDownPage() {
		return downPage;
	}
	public void setDownPage(int downPage) {
		this.downPage = downPage;
	}
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("{\"currentPage\":\"");
		builder.append(currentPage);
		builder.append("\",\"pageSize\":\"");
		builder.append(pageSize);
		builder.append("\",\"pageCount\":\"");
		builder.append(pageCount);
		builder.append("\",\"count\":\"");
		builder.append(count);
		builder.append("\",\"start\":\"");
		builder.append(start);
		builder.append("\",\"upPage\":\"");
		builder.append(upPage);
		builder.append("\",\"downPage\":\"");
		builder.append(downPage);
		builder.append("\"}");
		return builder.toString();
	}
	
}
